'''
测试一个经典GUI程序的写法，使用面向对象的方式
'''

from tkinter import *
from tkinter import messagebox

class Application(Frame):

    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.pack()
        self.createEidget()

    def createEidget(self):
        '''创建登录界面的组件'''
        self.lable01 = Label(self,text = "用户名")
        self.lable01.pack()

        v1 = StringVar()
        self.entry01 = Entry(self, textvariable = v1)
        self.entry01.pack()
        v1.set("zhanghao")

        '''创建密码框'''
        self.lable03 = Label(self,text = "密码")
        self.lable03.pack()

        v2 = StringVar()
        self.entry02 = Entry(self, textvariable = v2)
        self.entry02.pack()
        v2.set("mima")



        self.btn01 = Button(self,text = "登录",command = self.login)
        self.btn01.pack()





    def login(self):
        username = self.entry01.get()
        password = self.entry02.get()
        print(username)
        print(password)


if __name__ == '__main__':
    root = Tk()
    root.geometry("600x500+200+300")
    app = Application(master=root)
    root.mainloop()